#ifndef	__XML_REF_XMLNAME_H__
#define	__XML_REF_XMLNAME_H__

namespace BFX
{

//////////////////////////////////////////////////////////////////////////////

class REFXMLName : public REFObject
{
public:
	static REFXMLName* Create(const UniString& strPrefix, const UniString& strLocalName, const UniString& strNs, REFXMLDocument* pOwnerDoc);
	
	virtual ~REFXMLName();

	UniString GetLocalName() const
	{
		return m_strLocalName;
	}
	UniString GetNamespaceURI() const
	{
		return m_strNs;
	}
	UniString GetPrefix() const
	{
		return m_strPrefix;
	}
	REFXMLDocument* GetOwnerDocument() const
	{
		return m_pOwnerDoc;
	}
	UniString GetName() const;

	virtual bool Equals(REFXMLName* pName) const
	{
		if (this == pName)
			return true;
		else if (pName == NULL)
			return false;
		else
			return (m_strLocalName == pName->m_strLocalName && m_strNs == pName->m_strNs && m_strPrefix == pName->m_strPrefix);
		// ??? return (pName == NULL);
	}

protected:
	REFXMLName(const UniString& strPrefix, const UniString& strLocalName, const UniString& strNs, REFXMLDocument* pOwnerDoc);

private:
	UniString	m_strPrefix;
	UniString	m_strLocalName;
	UniString	m_strNs;
	mutable UniString	m_strName;
	REFXMLDocument*	m_pOwnerDoc;
};

//////////////////////////////////////////////////////////////////////////////
// Special versions of HashTraits for REF<REFXMLName>.
template<>
class HashTraits<REF<REFXMLName> >
{
public:
	static int __cdecl GetHashCode(REFXMLName* pName) throw()
	{
		typedef HashTraits<UniString> StrHashTraits;
		if (pName == NULL)
			return 0;	// NOTE: NULL value is also allowed.
		return StrHashTraits::GetHashCode(pName->GetName());
	}
	static bool __cdecl Equals(REFXMLName* pName1, REFXMLName* pName2) throw()
	{
		if (pName1 == NULL || pName2 == NULL)
			return pName1 == pName2;
		return pName1->Equals(pName2);
	}
};

}	//	namespace BFX

#endif	//	__XML_REF_XMLNAME_H__
